package com.qf.lanzhou.blog.api.controller.login;

import com.qf.lanzhou.blog.api.controller.BaseServletPost;
import com.qf.lanzhou.blog.api.pojo.entity.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @author jack
 */
@WebServlet("/checkLogin.do")
public class CheckLoginServlet extends BaseServletPost {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("检查登录");
        HttpSession session = req.getSession();
        User user = (User) session.getAttribute("user");
        if (user!=null){
            String msg = "你已经登录";
            failedResultWrite(msg,resp);
            return;
        }
        Object o = new Object();
        successResultWrite(o,resp);
    }
}